<?php
class TrainningClass {
    var $classId;
    var $className;
    var $student; //Khong can bien nay lam, student se lien ket qua day
    
     function __construct($cId,$cName,$cStudent){
        $this->classId=$cId;
        $this->className=$cName;
        $this->student=$cStudent;
	}
    
    function getClassId(){
        return $this->classId;
    }
    function setClassId($newClassId){
        $this->classId = $newClassId;
    }  
    function getClassName(){
        return $this->className;
    }
     function setClassName($newClassName){
        $this->className = $newClassName;
    }
     function getClassStudent(){
        return $this->student;
    }
    function setClassStudent($newClassStudent){
        $this->student = $newClassStudent;
    } 
    
    function getAllClassInProgram($programID) {
		$sql = "SELECT * FROM `trainningclass` WHERE `TRNP_ID` LIKE '".$programID."'";
		$query = mysql_query($sql); 

		$list = array();
		while($row=mysql_fetch_array($query)) { 
			$temp = new TrainningClass($row["CLASS_ID"],$row["CLASS_NAME"],null);
			$list[] = $temp;
		}
		return $list;
	}
	
	function getIDOfClassInProgram($programID) {
		$sql = "SELECT * FROM `trainningclass` WHERE `TRNP_ID` LIKE '".$programID."'";
		$query = mysql_query($sql); 

		$list = array();
		while($row=mysql_fetch_array($query)) {
			$list[] = $row["CLASS_ID"];
		}
		return $list;
	}
    function addClass($classid,$trnpid,$staffid,$classname){
      $sql = "INSERT INTO `trainningclass` (CLASS_ID,TRNP_ID,STAFF_ID,CLASS_NAME) VALUES('".$classid."','".$trnpid."','".$staffid."','".$classname."')";
      mysql_query($sql);
    }
    function editClass($classid,$trnpid,$staffid,$classname){
        $sql = "UPDATE trainningclass SET TRNP_ID='".$trnpid."',STAFF_ID='".$staffid."',CLASS_NAME='".$classname."' WHERE CLASS_ID='".$classid."'";
        mysql_query($sql);
    }
    function deleteClass($classid){
        $sql = "DELETE FROM trainningclass WHERE CLASS_ID='".$classid."'";
        mysql_query($sql);
    }
}



?>